package cn.botter.auth.domain.service.impl;

import cn.botter.auth.common.enums.IsDeletedEnum;
import cn.botter.auth.domain.convert.AuthRoleConvert;
import cn.botter.auth.domain.entity.AuthRoleBO;
import cn.botter.auth.domain.service.AuthRoleDomainService;
import cn.botter.auth.infra.basic.entity.AuthRole;
import cn.botter.auth.infra.basic.service.AuthRoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @BelongsProject: bo-club
 * @BelongsPackage: cn.botter.auth.domain.service.impl
 * @Author: 爱写Bug的Botter
 * @CreateTime: 2025-03-17:08:28
 * @Description: 描述
 * @Version: 1.0
 */
@Service
@Slf4j
public class AuthRoleDomainServiceImpl implements AuthRoleDomainService {
    @Resource
    private AuthRoleService authRoleService;
    @Override
    public Boolean add(AuthRoleBO authRoleBO) {
        AuthRole authRole = AuthRoleConvert.INSTANCE.convertBoToRole(authRoleBO);
        authRole.setIsDeleted(IsDeletedEnum.UN_DELETED.getCode());
        return authRoleService.insert(authRole) > 0;
    }

    @Override
    public Boolean update(AuthRoleBO authRoleBO) {
        AuthRole authRole = AuthRoleConvert.INSTANCE.convertBoToRole(authRoleBO);

        return authRoleService.update(authRole) > 0;

    }

    @Override
    public Boolean delete(AuthRoleBO authRoleBO) {
        AuthRole authRole = AuthRoleConvert.INSTANCE.convertBoToRole(authRoleBO);
        authRole.setIsDeleted(IsDeletedEnum.DELETED.getCode());
        return authRoleService.update(authRole) > 0;
    }
}
